# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Newbyte <newbyte@postmarketos.org>
pkgname=gcr4
pkgver=4.2.0
pkgrel=0
pkgdesc="Library for bits of crypto UI and parsing"
url="https://wiki.gnome.org/Projects/CryptoGlue"
arch="all"
license="LGPL-2.0-or-later"
makedepends="
	glib-dev
	gobject-introspection-dev
	gtk-doc
	gtk4.0-dev
	libgcrypt-dev
	libsecret-dev
	libxslt
	meson
	openssh-client
	p11-kit-dev
	vala
	"
checkdepends="
	bash
	dbus
	xvfb-run
	"
subpackages="
	$pkgname-dev
	$pkgname-lang
	$pkgname-base
	"
source="https://download.gnome.org/sources/gcr/${pkgver%.*}/gcr-$pkgver.tar.xz"
builddir="$srcdir/gcr-$pkgver"
options="!check" # fix later after p11-kit fixes

build() {
	abuild-meson \
		-Db_lto=true \
		-Dgtk_doc=false \
		-Dgpg_path=/usr/bin/gpg2 \
		-Dsystemd=disabled \
		. output
	meson compile -C output
}

check() {
	XDG_RUNTIME_DIR="$(mktemp -d -p "$builddir")" \
	dbus-run-session -- \
		xvfb-run -a \
		meson test -t10 --no-rebuild --print-errorlogs -C output
}

package() {
	depends="gcr-ssh-agent"
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	rm "$pkgdir"/usr/libexec/gcr-ssh-agent
}

base() {
	pkgdesc="$pkgdesc (base libraries)"
	depends=""

	amove usr/lib
}

sha512sums="
81e688d2adf256bd3f1eb24b32e6f6709ce48bf2159617c3a39c03ae71385941ac2bac75cf23060d7582dbb4a934d924bda20dc3d524c3d359f2e46cd202ad88  gcr-4.2.0.tar.xz
"
